import upperCamelCase from 'uppercamelcase';
import ImweMap from './component/imwe-map.vue'
import ImweMarker from './component/imwe-marker.vue'
import ImweMarkerCluster from './component/imwe-marker-cluster.vue'

const components = [
    ImweMap,
    ImweMarker,
    ImweMarkerCluster
]
let VueAMap = {}

VueAMap.install = (Vue) => {
    if (VueAMap.installed) return;
    Vue.config.optionMergeStrategies.deferredReady = Vue.config.optionMergeStrategies.created;
    components.map(_component => {
        // register component

        Vue.component(_component.name, _component);

        // component cache
        VueAMap[upperCamelCase(_component.name).replace(/^El/, '')] = _component;
    });
};

// setTimeout(() => {
//     console.log('ImweMap', ImweMap);
//     components.map(_component => {
//         console.log('component', _component);
//         // VueAMap[upperCamelCase(component.name).replace(/^El/, '')] = component
//     })
// }, 1000)

export default VueAMap
